package com.zq.zhufengfm.entity.discoverrecommened;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.LinkedList;
import java.util.List;

/**
 * Project_name : ZhuFengFM
 * Author : zhaoQiang
 * Date : 2015/10/21,11:35
 * Email : zhaoq_hero@163.com
 */
public class DiscoverRecommendAlubums extends DiscoverRecommendItem{

    /*
           "ret" : 0
           "title" :小编推荐
           "hasMore" : true
           "list" : []
     */

    private int ret;

    /**
     * 推荐的专辑
     */
    private List<AlbumRecommend> albumRecommendsList;

    public void parseJSON(JSONObject jsonObject) throws JSONException {

        //调用父类的解析方法
        //因为super中包含了title和  hasmore
        super.parseJSON(jsonObject);


        ret = jsonObject.optInt("ret");


        //
        JSONArray array = jsonObject.getJSONArray("list");


        albumRecommendsList = new LinkedList<AlbumRecommend>();
        //开始解析：

        if(array.length()>0){

            for (int i = 0; i < array.length(); i++) {

                //解析专辑内部推荐：
                JSONObject json = array.getJSONObject(i);
                AlbumRecommend album = new AlbumRecommend();

                album.parseJSON(json);

                albumRecommendsList.add(album);

            }
        }
    }

    public List<AlbumRecommend> getAlbumRecommendsList() {
        return albumRecommendsList;
    }

}
